



// This code is a generated code by a tool
// designed and coded by Shohdi Mohamed Elsheemy ( shohdi@gmail.com )            

using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Common;
using Shohdi.DataHandler;
using System.Data;




namespace DatabaseComponent
{
    
    public partial class RegisteredCoursesDB
    {
         string _Connection = "";


        public string Connection
        {
            get { return _Connection; }
            set { _Connection = value; }
        }


       
         string _Provider = "System.Data.SqlClient";

        
        public string Provider
        {
            get { return _Provider; }
            set { _Provider = value; }
        }



        public RegisteredCoursesDB()
        {
        }

        public RegisteredCoursesDB(string __Connection,params string [] __Provider)
        {

            if (__Provider.Length > 0)
                _Provider = __Provider[0];

            _Connection = __Connection;
            
        }




        public List<RegisteredCourses> Select(ClassDataHandler con, string strTop, string strWhere, params DbParameter[] whereParams)
        {
            if (whereParams == null)
                whereParams = new DbParameter[0];

            List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

            string strQuery = " select " + strTop  + " * from dbo.[RegisteredCourses]  " ;

            if (strWhere != "")
            {
                strQuery = strQuery + "  " + strWhere;
            }

            DbDataReader dr = con.SelectDataReader(strQuery, CommandType.Text, whereParams);


            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    RegisteredCourses obj = new RegisteredCourses();
 if (dr["ID"] != DBNull.Value)
                    {
                        obj.ID = (System.Int64)dr["ID"];
                    }
                    else
                    {
                        obj.ID = -1;
                    } 
 if (dr["CoursesID"] != DBNull.Value)
                    {
                        obj.CoursesID = (System.Int64)dr["CoursesID"];
                    }
                    else
                    {
                        obj.CoursesID = -1;
                    } 
 if (dr["EmployeesID"] != DBNull.Value)
                    {
                        obj.EmployeesID = (System.Int64)dr["EmployeesID"];
                    }
                    else
                    {
                        obj.EmployeesID = -1;
                    } 
 if (dr["StartDate"] != DBNull.Value)
                    {
                        obj.StartDate = (System.DateTime?)dr["StartDate"];
                    }
                    else
                    {
                        obj.StartDate = null;
                    } 
 if (dr["CurrentData"] != DBNull.Value)
                    {
                        obj.CurrentData = (System.String)dr["CurrentData"];
                    }
                    else
                    {
                        obj.CurrentData = "";
                    } 
 if (dr["LastSlide"] != DBNull.Value)
                    {
                        obj.LastSlide = (System.Int64?)dr["LastSlide"];
                    }
                    else
                    {
                        obj.LastSlide = null;
                    } 
 if (dr["TotalSlides"] != DBNull.Value)
                    {
                        obj.TotalSlides = (System.Int64?)dr["TotalSlides"];
                    }
                    else
                    {
                        obj.TotalSlides = null;
                    } 
 if (dr["CourseStatus"] != DBNull.Value)
                    {
                        obj.CourseStatus = (System.Int64)dr["CourseStatus"];
                    }
                    else
                    {
                        obj.CourseStatus = -1;
                    } 
 if (dr["ExamDegree"] != DBNull.Value)
                    {
                        obj.ExamDegree = (System.Int64?)dr["ExamDegree"];
                    }
                    else
                    {
                        obj.ExamDegree = null;
                    } 
 if (dr["EndDate"] != DBNull.Value)
                    {
                        obj.EndDate = (System.DateTime?)dr["EndDate"];
                    }
                    else
                    {
                        obj.EndDate = null;
                    } 
 if (dr["NoOfTicks"] != DBNull.Value)
                    {
                        obj.NoOfTicks = (System.Int64?)dr["NoOfTicks"];
                    }
                    else
                    {
                        obj.NoOfTicks = null;
                    } 
 if (dr["LastTickDate"] != DBNull.Value)
                    {
                        obj.LastTickDate = (System.DateTime?)dr["LastTickDate"];
                    }
                    else
                    {
                        obj.LastTickDate = null;
                    } 
 if (dr["TotalSpendTime"] != DBNull.Value)
                    {
                        obj.TotalSpendTime = (System.Int64)dr["TotalSpendTime"];
                    }
                    else
                    {
                        obj.TotalSpendTime = -1;
                    } 



                    lstRet.Add(obj);
                   

                }
            }

            dr.Close();


            return lstRet;
        }


        public List<RegisteredCourses> Select(string strTop, string strWhere, params DbParameter[] whereParams)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<RegisteredCourses> lstRet = Select(con, strTop, strWhere, whereParams);

            con.CloseConnection();

            return lstRet;
        }

        



        public void Insert(ClassDataHandler con , RegisteredCourses obj)
        {
            
            

                    DbParameter prmCoursesID = con.createParameter();
                    prmCoursesID.ParameterName = "@CoursesID";
                    prmCoursesID.DbType =DbType.Int64;
                    if (obj.CoursesID == null)
                    {
                        prmCoursesID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCoursesID.Value = obj.CoursesID;
                    }
                

                    


                    DbParameter prmEmployeesID = con.createParameter();
                    prmEmployeesID.ParameterName = "@EmployeesID";
                    prmEmployeesID.DbType =DbType.Int64;
                    if (obj.EmployeesID == null)
                    {
                        prmEmployeesID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmployeesID.Value = obj.EmployeesID;
                    }
                

                    


                    DbParameter prmStartDate = con.createParameter();
                    prmStartDate.ParameterName = "@StartDate";
                    prmStartDate.DbType =DbType.DateTime;
                    if (obj.StartDate == null)
                    {
                        prmStartDate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmStartDate.Value = obj.StartDate;
                    }
                

                    


                    DbParameter prmCurrentData = con.createParameter();
                    prmCurrentData.ParameterName = "@CurrentData";
                    prmCurrentData.DbType =DbType.String;
                    if (obj.CurrentData == null)
                    {
                        prmCurrentData.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCurrentData.Value = obj.CurrentData;
                    }
                

                    


                    DbParameter prmLastSlide = con.createParameter();
                    prmLastSlide.ParameterName = "@LastSlide";
                    prmLastSlide.DbType =DbType.Int64;
                    if (obj.LastSlide == null)
                    {
                        prmLastSlide.Value = DBNull.Value;
                    }
                    else
                    {
                        prmLastSlide.Value = obj.LastSlide;
                    }
                

                    


                    DbParameter prmTotalSlides = con.createParameter();
                    prmTotalSlides.ParameterName = "@TotalSlides";
                    prmTotalSlides.DbType =DbType.Int64;
                    if (obj.TotalSlides == null)
                    {
                        prmTotalSlides.Value = DBNull.Value;
                    }
                    else
                    {
                        prmTotalSlides.Value = obj.TotalSlides;
                    }
                

                    


                    DbParameter prmCourseStatus = con.createParameter();
                    prmCourseStatus.ParameterName = "@CourseStatus";
                    prmCourseStatus.DbType =DbType.Int64;
                    if (obj.CourseStatus == null)
                    {
                        prmCourseStatus.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCourseStatus.Value = obj.CourseStatus;
                    }
                

                    


                    DbParameter prmExamDegree = con.createParameter();
                    prmExamDegree.ParameterName = "@ExamDegree";
                    prmExamDegree.DbType =DbType.Int64;
                    if (obj.ExamDegree == null)
                    {
                        prmExamDegree.Value = DBNull.Value;
                    }
                    else
                    {
                        prmExamDegree.Value = obj.ExamDegree;
                    }
                

                    


                    DbParameter prmEndDate = con.createParameter();
                    prmEndDate.ParameterName = "@EndDate";
                    prmEndDate.DbType =DbType.DateTime;
                    if (obj.EndDate == null)
                    {
                        prmEndDate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEndDate.Value = obj.EndDate;
                    }
                

                    


                    DbParameter prmNoOfTicks = con.createParameter();
                    prmNoOfTicks.ParameterName = "@NoOfTicks";
                    prmNoOfTicks.DbType =DbType.Int64;
                    if (obj.NoOfTicks == null)
                    {
                        prmNoOfTicks.Value = DBNull.Value;
                    }
                    else
                    {
                        prmNoOfTicks.Value = obj.NoOfTicks;
                    }
                

                    


                    DbParameter prmLastTickDate = con.createParameter();
                    prmLastTickDate.ParameterName = "@LastTickDate";
                    prmLastTickDate.DbType =DbType.DateTime;
                    if (obj.LastTickDate == null)
                    {
                        prmLastTickDate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmLastTickDate.Value = obj.LastTickDate;
                    }
                

                    


                    DbParameter prmTotalSpendTime = con.createParameter();
                    prmTotalSpendTime.ParameterName = "@TotalSpendTime";
                    prmTotalSpendTime.DbType =DbType.Int64;
                    if (obj.TotalSpendTime == null)
                    {
                        prmTotalSpendTime.Value = DBNull.Value;
                    }
                    else
                    {
                        prmTotalSpendTime.Value = obj.TotalSpendTime;
                    }
                

                    


           



            string strQuery = " insert into dbo.[RegisteredCourses] ([CoursesID],[EmployeesID],[StartDate],[CurrentData],[LastSlide],[TotalSlides],[CourseStatus],[ExamDegree],[EndDate],[NoOfTicks],[LastTickDate],[TotalSpendTime]) VALUES (@CoursesID,@EmployeesID,@StartDate,@CurrentData,@LastSlide,@TotalSlides,@CourseStatus,@ExamDegree,@EndDate,@NoOfTicks,@LastTickDate,@TotalSpendTime) ; select SCOPE_IDENTITY() ";
 object scope = con.ExecuteScalar(strQuery, CommandType.Text, prmCoursesID,prmEmployeesID,prmStartDate,prmCurrentData,prmLastSlide,prmTotalSlides,prmCourseStatus,prmExamDegree,prmEndDate,prmNoOfTicks,prmLastTickDate,prmTotalSpendTime);


                    try
                    {
                        obj.ID = System.Int64.Parse(scope.ToString());
                    }
                    catch
                    {
                        obj.ID = -1;
                    }


                    


           

        }



        public void Insert(RegisteredCourses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Insert(con,obj);


            con.CloseConnection();
        }




        public void Update(ClassDataHandler con, RegisteredCourses obj)
        {
            
            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


                    DbParameter prmCoursesID = con.createParameter();
                    prmCoursesID.ParameterName = "@CoursesID";
                    prmCoursesID.DbType =DbType.Int64;
                    if (obj.CoursesID == null)
                    {
                        prmCoursesID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCoursesID.Value = obj.CoursesID;
                    }
                

                    


                    DbParameter prmEmployeesID = con.createParameter();
                    prmEmployeesID.ParameterName = "@EmployeesID";
                    prmEmployeesID.DbType =DbType.Int64;
                    if (obj.EmployeesID == null)
                    {
                        prmEmployeesID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmployeesID.Value = obj.EmployeesID;
                    }
                

                    


                    DbParameter prmStartDate = con.createParameter();
                    prmStartDate.ParameterName = "@StartDate";
                    prmStartDate.DbType =DbType.DateTime;
                    if (obj.StartDate == null)
                    {
                        prmStartDate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmStartDate.Value = obj.StartDate;
                    }
                

                    


                    DbParameter prmCurrentData = con.createParameter();
                    prmCurrentData.ParameterName = "@CurrentData";
                    prmCurrentData.DbType =DbType.String;
                    if (obj.CurrentData == null)
                    {
                        prmCurrentData.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCurrentData.Value = obj.CurrentData;
                    }
                

                    


                    DbParameter prmLastSlide = con.createParameter();
                    prmLastSlide.ParameterName = "@LastSlide";
                    prmLastSlide.DbType =DbType.Int64;
                    if (obj.LastSlide == null)
                    {
                        prmLastSlide.Value = DBNull.Value;
                    }
                    else
                    {
                        prmLastSlide.Value = obj.LastSlide;
                    }
                

                    


                    DbParameter prmTotalSlides = con.createParameter();
                    prmTotalSlides.ParameterName = "@TotalSlides";
                    prmTotalSlides.DbType =DbType.Int64;
                    if (obj.TotalSlides == null)
                    {
                        prmTotalSlides.Value = DBNull.Value;
                    }
                    else
                    {
                        prmTotalSlides.Value = obj.TotalSlides;
                    }
                

                    


                    DbParameter prmCourseStatus = con.createParameter();
                    prmCourseStatus.ParameterName = "@CourseStatus";
                    prmCourseStatus.DbType =DbType.Int64;
                    if (obj.CourseStatus == null)
                    {
                        prmCourseStatus.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCourseStatus.Value = obj.CourseStatus;
                    }
                

                    


                    DbParameter prmExamDegree = con.createParameter();
                    prmExamDegree.ParameterName = "@ExamDegree";
                    prmExamDegree.DbType =DbType.Int64;
                    if (obj.ExamDegree == null)
                    {
                        prmExamDegree.Value = DBNull.Value;
                    }
                    else
                    {
                        prmExamDegree.Value = obj.ExamDegree;
                    }
                

                    


                    DbParameter prmEndDate = con.createParameter();
                    prmEndDate.ParameterName = "@EndDate";
                    prmEndDate.DbType =DbType.DateTime;
                    if (obj.EndDate == null)
                    {
                        prmEndDate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEndDate.Value = obj.EndDate;
                    }
                

                    


                    DbParameter prmNoOfTicks = con.createParameter();
                    prmNoOfTicks.ParameterName = "@NoOfTicks";
                    prmNoOfTicks.DbType =DbType.Int64;
                    if (obj.NoOfTicks == null)
                    {
                        prmNoOfTicks.Value = DBNull.Value;
                    }
                    else
                    {
                        prmNoOfTicks.Value = obj.NoOfTicks;
                    }
                

                    


                    DbParameter prmLastTickDate = con.createParameter();
                    prmLastTickDate.ParameterName = "@LastTickDate";
                    prmLastTickDate.DbType =DbType.DateTime;
                    if (obj.LastTickDate == null)
                    {
                        prmLastTickDate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmLastTickDate.Value = obj.LastTickDate;
                    }
                

                    


                    DbParameter prmTotalSpendTime = con.createParameter();
                    prmTotalSpendTime.ParameterName = "@TotalSpendTime";
                    prmTotalSpendTime.DbType =DbType.Int64;
                    if (obj.TotalSpendTime == null)
                    {
                        prmTotalSpendTime.Value = DBNull.Value;
                    }
                    else
                    {
                        prmTotalSpendTime.Value = obj.TotalSpendTime;
                    }
                

                    


           



            string strQuery = " update dbo.[RegisteredCourses] set [CoursesID]=@CoursesID,[EmployeesID]=@EmployeesID,[StartDate]=@StartDate,[CurrentData]=@CurrentData,[LastSlide]=@LastSlide,[TotalSlides]=@TotalSlides,[CourseStatus]=@CourseStatus,[ExamDegree]=@ExamDegree,[EndDate]=@EndDate,[NoOfTicks]=@NoOfTicks,[LastTickDate]=@LastTickDate,[TotalSpendTime]=@TotalSpendTime where  [ID]=@ID  ";

            con.ExecuteNonQuery(strQuery, CommandType.Text,prmID,prmCoursesID,prmEmployeesID,prmStartDate,prmCurrentData,prmLastSlide,prmTotalSlides,prmCourseStatus,prmExamDegree,prmEndDate,prmNoOfTicks,prmLastTickDate,prmTotalSpendTime);

            

        }


        public void Update(RegisteredCourses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Update(con, obj);


            con.CloseConnection();
        }



        public void Delete(ClassDataHandler con, RegisteredCourses obj)
        {

            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


           



           



            string strQuery = " delete from dbo.[RegisteredCourses]  where  [ID]=@ID  "; 
                        con.ExecuteNonQuery(strQuery, CommandType.Text,prmID );  

             



        }


        public void Delete( RegisteredCourses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            Delete(con, obj);

            con.CloseConnection();
        }





                    public List<RegisteredCourses> getRegisteredCoursesByID(ClassDataHandler con,System.Int64 ID)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType = DbType.Int64;
                        if (ID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmID.Value = ID;
                        }


                        lstRet = Select(con, "" , " where [ID]=@ID ", prmID);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByID(System.Int64 ID)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByID(con, ID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByCoursesID(ClassDataHandler con,System.Int64 CoursesID)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmCoursesID = con.createParameter();
                        prmCoursesID.ParameterName = "@CoursesID";
                        prmCoursesID.DbType = DbType.Int64;
                        if (CoursesID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmCoursesID.Value = CoursesID;
                        }


                        lstRet = Select(con, "" , " where [CoursesID]=@CoursesID ", prmCoursesID);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByCoursesID(System.Int64 CoursesID)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByCoursesID(con, CoursesID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByEmployeesID(ClassDataHandler con,System.Int64 EmployeesID)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmEmployeesID = con.createParameter();
                        prmEmployeesID.ParameterName = "@EmployeesID";
                        prmEmployeesID.DbType = DbType.Int64;
                        if (EmployeesID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmEmployeesID.Value = EmployeesID;
                        }


                        lstRet = Select(con, "" , " where [EmployeesID]=@EmployeesID ", prmEmployeesID);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByEmployeesID(System.Int64 EmployeesID)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByEmployeesID(con, EmployeesID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByStartDate(ClassDataHandler con,System.DateTime? StartDate)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmStartDate = con.createParameter();
                        prmStartDate.ParameterName = "@StartDate";
                        prmStartDate.DbType = DbType.DateTime;
                        if (StartDate == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmStartDate.Value = StartDate;
                        }


                        lstRet = Select(con, "" , " where [StartDate]=@StartDate ", prmStartDate);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByStartDate(System.DateTime? StartDate)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByStartDate(con, StartDate);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByCurrentData(ClassDataHandler con,System.String CurrentData)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmCurrentData = con.createParameter();
                        prmCurrentData.ParameterName = "@CurrentData";
                        prmCurrentData.DbType = DbType.String;
                        if (CurrentData == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmCurrentData.Value = CurrentData;
                        }


                        lstRet = Select(con, "" , " where [CurrentData]=@CurrentData ", prmCurrentData);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByCurrentData(System.String CurrentData)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByCurrentData(con, CurrentData);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByLastSlide(ClassDataHandler con,System.Int64? LastSlide)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmLastSlide = con.createParameter();
                        prmLastSlide.ParameterName = "@LastSlide";
                        prmLastSlide.DbType = DbType.Int64;
                        if (LastSlide == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmLastSlide.Value = LastSlide;
                        }


                        lstRet = Select(con, "" , " where [LastSlide]=@LastSlide ", prmLastSlide);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByLastSlide(System.Int64? LastSlide)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByLastSlide(con, LastSlide);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByTotalSlides(ClassDataHandler con,System.Int64? TotalSlides)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmTotalSlides = con.createParameter();
                        prmTotalSlides.ParameterName = "@TotalSlides";
                        prmTotalSlides.DbType = DbType.Int64;
                        if (TotalSlides == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmTotalSlides.Value = TotalSlides;
                        }


                        lstRet = Select(con, "" , " where [TotalSlides]=@TotalSlides ", prmTotalSlides);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByTotalSlides(System.Int64? TotalSlides)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByTotalSlides(con, TotalSlides);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByCourseStatus(ClassDataHandler con,System.Int64 CourseStatus)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmCourseStatus = con.createParameter();
                        prmCourseStatus.ParameterName = "@CourseStatus";
                        prmCourseStatus.DbType = DbType.Int64;
                        if (CourseStatus == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmCourseStatus.Value = CourseStatus;
                        }


                        lstRet = Select(con, "" , " where [CourseStatus]=@CourseStatus ", prmCourseStatus);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByCourseStatus(System.Int64 CourseStatus)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByCourseStatus(con, CourseStatus);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByExamDegree(ClassDataHandler con,System.Int64? ExamDegree)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmExamDegree = con.createParameter();
                        prmExamDegree.ParameterName = "@ExamDegree";
                        prmExamDegree.DbType = DbType.Int64;
                        if (ExamDegree == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmExamDegree.Value = ExamDegree;
                        }


                        lstRet = Select(con, "" , " where [ExamDegree]=@ExamDegree ", prmExamDegree);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByExamDegree(System.Int64? ExamDegree)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByExamDegree(con, ExamDegree);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByEndDate(ClassDataHandler con,System.DateTime? EndDate)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmEndDate = con.createParameter();
                        prmEndDate.ParameterName = "@EndDate";
                        prmEndDate.DbType = DbType.DateTime;
                        if (EndDate == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmEndDate.Value = EndDate;
                        }


                        lstRet = Select(con, "" , " where [EndDate]=@EndDate ", prmEndDate);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByEndDate(System.DateTime? EndDate)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByEndDate(con, EndDate);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByNoOfTicks(ClassDataHandler con,System.Int64? NoOfTicks)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmNoOfTicks = con.createParameter();
                        prmNoOfTicks.ParameterName = "@NoOfTicks";
                        prmNoOfTicks.DbType = DbType.Int64;
                        if (NoOfTicks == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmNoOfTicks.Value = NoOfTicks;
                        }


                        lstRet = Select(con, "" , " where [NoOfTicks]=@NoOfTicks ", prmNoOfTicks);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByNoOfTicks(System.Int64? NoOfTicks)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByNoOfTicks(con, NoOfTicks);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByLastTickDate(ClassDataHandler con,System.DateTime? LastTickDate)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmLastTickDate = con.createParameter();
                        prmLastTickDate.ParameterName = "@LastTickDate";
                        prmLastTickDate.DbType = DbType.DateTime;
                        if (LastTickDate == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmLastTickDate.Value = LastTickDate;
                        }


                        lstRet = Select(con, "" , " where [LastTickDate]=@LastTickDate ", prmLastTickDate);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByLastTickDate(System.DateTime? LastTickDate)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByLastTickDate(con, LastTickDate);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<RegisteredCourses> getRegisteredCoursesByTotalSpendTime(ClassDataHandler con,System.Int64 TotalSpendTime)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();


                        DbParameter prmTotalSpendTime = con.createParameter();
                        prmTotalSpendTime.ParameterName = "@TotalSpendTime";
                        prmTotalSpendTime.DbType = DbType.Int64;
                        if (TotalSpendTime == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmTotalSpendTime.Value = TotalSpendTime;
                        }


                        lstRet = Select(con, "" , " where [TotalSpendTime]=@TotalSpendTime ", prmTotalSpendTime);



                        return lstRet;

                    }


                    public List<RegisteredCourses> getRegisteredCoursesByTotalSpendTime(System.Int64 TotalSpendTime)
                    {
                        List<RegisteredCourses> lstRet = new List<RegisteredCourses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getRegisteredCoursesByTotalSpendTime(con, TotalSpendTime);

                        con.CloseConnection();

                        return lstRet;

                    }



                

            
public List<RegisteredCourses> Search(ClassDataHandler con, RegisteredCourses obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID AND ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.CoursesID != -1)
                    {
                        DbParameter prmCoursesID = con.createParameter();
                        prmCoursesID.ParameterName = "@CoursesID";
                        prmCoursesID.DbType =DbType.Int64;
                        if (obj.CoursesID == null)
                        {
                            prmCoursesID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCoursesID.Value = obj.CoursesID;
                        }
                        strWhere += " [CoursesID]=@CoursesID AND ";
                        lstParameters.Add(prmCoursesID);
                     }



                    

                    if (obj.EmployeesID != -1)
                    {
                        DbParameter prmEmployeesID = con.createParameter();
                        prmEmployeesID.ParameterName = "@EmployeesID";
                        prmEmployeesID.DbType =DbType.Int64;
                        if (obj.EmployeesID == null)
                        {
                            prmEmployeesID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmployeesID.Value = obj.EmployeesID;
                        }
                        strWhere += " [EmployeesID]=@EmployeesID AND ";
                        lstParameters.Add(prmEmployeesID);
                     }



                    

                    if (obj.StartDate != null)
                    {
                        DbParameter prmStartDate = con.createParameter();
                        prmStartDate.ParameterName = "@StartDate";
                        prmStartDate.DbType =DbType.DateTime;
                        if (obj.StartDate == null)
                        {
                            prmStartDate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmStartDate.Value = obj.StartDate;
                        }
                        strWhere += " [StartDate]=@StartDate AND ";
                        lstParameters.Add(prmStartDate);
                     }



                    

                    if (obj.CurrentData != "")
                    {
                        DbParameter prmCurrentData = con.createParameter();
                        prmCurrentData.ParameterName = "@CurrentData";
                        prmCurrentData.DbType =DbType.String;
                        if (obj.CurrentData == null)
                        {
                            prmCurrentData.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCurrentData.Value = obj.CurrentData;
                        }
                        strWhere += " [CurrentData]=@CurrentData AND ";
                        lstParameters.Add(prmCurrentData);
                     }



                    

                    if (obj.LastSlide != null)
                    {
                        DbParameter prmLastSlide = con.createParameter();
                        prmLastSlide.ParameterName = "@LastSlide";
                        prmLastSlide.DbType =DbType.Int64;
                        if (obj.LastSlide == null)
                        {
                            prmLastSlide.Value = DBNull.Value;
                        }
                        else
                        {
                            prmLastSlide.Value = obj.LastSlide;
                        }
                        strWhere += " [LastSlide]=@LastSlide AND ";
                        lstParameters.Add(prmLastSlide);
                     }



                    

                    if (obj.TotalSlides != null)
                    {
                        DbParameter prmTotalSlides = con.createParameter();
                        prmTotalSlides.ParameterName = "@TotalSlides";
                        prmTotalSlides.DbType =DbType.Int64;
                        if (obj.TotalSlides == null)
                        {
                            prmTotalSlides.Value = DBNull.Value;
                        }
                        else
                        {
                            prmTotalSlides.Value = obj.TotalSlides;
                        }
                        strWhere += " [TotalSlides]=@TotalSlides AND ";
                        lstParameters.Add(prmTotalSlides);
                     }



                    

                    if (obj.CourseStatus != -1)
                    {
                        DbParameter prmCourseStatus = con.createParameter();
                        prmCourseStatus.ParameterName = "@CourseStatus";
                        prmCourseStatus.DbType =DbType.Int64;
                        if (obj.CourseStatus == null)
                        {
                            prmCourseStatus.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCourseStatus.Value = obj.CourseStatus;
                        }
                        strWhere += " [CourseStatus]=@CourseStatus AND ";
                        lstParameters.Add(prmCourseStatus);
                     }



                    

                    if (obj.ExamDegree != null)
                    {
                        DbParameter prmExamDegree = con.createParameter();
                        prmExamDegree.ParameterName = "@ExamDegree";
                        prmExamDegree.DbType =DbType.Int64;
                        if (obj.ExamDegree == null)
                        {
                            prmExamDegree.Value = DBNull.Value;
                        }
                        else
                        {
                            prmExamDegree.Value = obj.ExamDegree;
                        }
                        strWhere += " [ExamDegree]=@ExamDegree AND ";
                        lstParameters.Add(prmExamDegree);
                     }



                    

                    if (obj.EndDate != null)
                    {
                        DbParameter prmEndDate = con.createParameter();
                        prmEndDate.ParameterName = "@EndDate";
                        prmEndDate.DbType =DbType.DateTime;
                        if (obj.EndDate == null)
                        {
                            prmEndDate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEndDate.Value = obj.EndDate;
                        }
                        strWhere += " [EndDate]=@EndDate AND ";
                        lstParameters.Add(prmEndDate);
                     }



                    

                    if (obj.NoOfTicks != null)
                    {
                        DbParameter prmNoOfTicks = con.createParameter();
                        prmNoOfTicks.ParameterName = "@NoOfTicks";
                        prmNoOfTicks.DbType =DbType.Int64;
                        if (obj.NoOfTicks == null)
                        {
                            prmNoOfTicks.Value = DBNull.Value;
                        }
                        else
                        {
                            prmNoOfTicks.Value = obj.NoOfTicks;
                        }
                        strWhere += " [NoOfTicks]=@NoOfTicks AND ";
                        lstParameters.Add(prmNoOfTicks);
                     }



                    

                    if (obj.LastTickDate != null)
                    {
                        DbParameter prmLastTickDate = con.createParameter();
                        prmLastTickDate.ParameterName = "@LastTickDate";
                        prmLastTickDate.DbType =DbType.DateTime;
                        if (obj.LastTickDate == null)
                        {
                            prmLastTickDate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmLastTickDate.Value = obj.LastTickDate;
                        }
                        strWhere += " [LastTickDate]=@LastTickDate AND ";
                        lstParameters.Add(prmLastTickDate);
                     }



                    

                    if (obj.TotalSpendTime != -1)
                    {
                        DbParameter prmTotalSpendTime = con.createParameter();
                        prmTotalSpendTime.ParameterName = "@TotalSpendTime";
                        prmTotalSpendTime.DbType =DbType.Int64;
                        if (obj.TotalSpendTime == null)
                        {
                            prmTotalSpendTime.Value = DBNull.Value;
                        }
                        else
                        {
                            prmTotalSpendTime.Value = obj.TotalSpendTime;
                        }
                        strWhere += " [TotalSpendTime]=@TotalSpendTime AND ";
                        lstParameters.Add(prmTotalSpendTime);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("AND"));

                    

            

            List<RegisteredCourses> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<RegisteredCourses> Search(RegisteredCourses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<RegisteredCourses> lstRet = Search(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                

            
public List<RegisteredCourses> SearchOrLike(ClassDataHandler con, RegisteredCourses obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID OR ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.CoursesID != -1)
                    {
                        DbParameter prmCoursesID = con.createParameter();
                        prmCoursesID.ParameterName = "@CoursesID";
                        prmCoursesID.DbType =DbType.Int64;
                        if (obj.CoursesID == null)
                        {
                            prmCoursesID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCoursesID.Value = obj.CoursesID;
                        }
                        strWhere += " [CoursesID]=@CoursesID OR ";
                        lstParameters.Add(prmCoursesID);
                     }



                    

                    if (obj.EmployeesID != -1)
                    {
                        DbParameter prmEmployeesID = con.createParameter();
                        prmEmployeesID.ParameterName = "@EmployeesID";
                        prmEmployeesID.DbType =DbType.Int64;
                        if (obj.EmployeesID == null)
                        {
                            prmEmployeesID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmployeesID.Value = obj.EmployeesID;
                        }
                        strWhere += " [EmployeesID]=@EmployeesID OR ";
                        lstParameters.Add(prmEmployeesID);
                     }



                    

                    if (obj.StartDate != null)
                    {
                        DbParameter prmStartDate = con.createParameter();
                        prmStartDate.ParameterName = "@StartDate";
                        prmStartDate.DbType =DbType.DateTime;
                        if (obj.StartDate == null)
                        {
                            prmStartDate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmStartDate.Value = obj.StartDate;
                        }
                        strWhere += " [StartDate]=@StartDate OR ";
                        lstParameters.Add(prmStartDate);
                     }



                    

                    if (obj.CurrentData != "")
                    {
                        DbParameter prmCurrentData = con.createParameter();
                        prmCurrentData.ParameterName = "@CurrentData";
                        prmCurrentData.DbType =DbType.String;
                        if (obj.CurrentData == null)
                        {
                            prmCurrentData.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCurrentData.Value = obj.CurrentData;
                        }
                        strWhere += " [CurrentData] LIKE @CurrentData OR ";
                        lstParameters.Add(prmCurrentData);
                     }



                    

                    if (obj.LastSlide != null)
                    {
                        DbParameter prmLastSlide = con.createParameter();
                        prmLastSlide.ParameterName = "@LastSlide";
                        prmLastSlide.DbType =DbType.Int64;
                        if (obj.LastSlide == null)
                        {
                            prmLastSlide.Value = DBNull.Value;
                        }
                        else
                        {
                            prmLastSlide.Value = obj.LastSlide;
                        }
                        strWhere += " [LastSlide]=@LastSlide OR ";
                        lstParameters.Add(prmLastSlide);
                     }



                    

                    if (obj.TotalSlides != null)
                    {
                        DbParameter prmTotalSlides = con.createParameter();
                        prmTotalSlides.ParameterName = "@TotalSlides";
                        prmTotalSlides.DbType =DbType.Int64;
                        if (obj.TotalSlides == null)
                        {
                            prmTotalSlides.Value = DBNull.Value;
                        }
                        else
                        {
                            prmTotalSlides.Value = obj.TotalSlides;
                        }
                        strWhere += " [TotalSlides]=@TotalSlides OR ";
                        lstParameters.Add(prmTotalSlides);
                     }



                    

                    if (obj.CourseStatus != -1)
                    {
                        DbParameter prmCourseStatus = con.createParameter();
                        prmCourseStatus.ParameterName = "@CourseStatus";
                        prmCourseStatus.DbType =DbType.Int64;
                        if (obj.CourseStatus == null)
                        {
                            prmCourseStatus.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCourseStatus.Value = obj.CourseStatus;
                        }
                        strWhere += " [CourseStatus]=@CourseStatus OR ";
                        lstParameters.Add(prmCourseStatus);
                     }



                    

                    if (obj.ExamDegree != null)
                    {
                        DbParameter prmExamDegree = con.createParameter();
                        prmExamDegree.ParameterName = "@ExamDegree";
                        prmExamDegree.DbType =DbType.Int64;
                        if (obj.ExamDegree == null)
                        {
                            prmExamDegree.Value = DBNull.Value;
                        }
                        else
                        {
                            prmExamDegree.Value = obj.ExamDegree;
                        }
                        strWhere += " [ExamDegree]=@ExamDegree OR ";
                        lstParameters.Add(prmExamDegree);
                     }



                    

                    if (obj.EndDate != null)
                    {
                        DbParameter prmEndDate = con.createParameter();
                        prmEndDate.ParameterName = "@EndDate";
                        prmEndDate.DbType =DbType.DateTime;
                        if (obj.EndDate == null)
                        {
                            prmEndDate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEndDate.Value = obj.EndDate;
                        }
                        strWhere += " [EndDate]=@EndDate OR ";
                        lstParameters.Add(prmEndDate);
                     }



                    

                    if (obj.NoOfTicks != null)
                    {
                        DbParameter prmNoOfTicks = con.createParameter();
                        prmNoOfTicks.ParameterName = "@NoOfTicks";
                        prmNoOfTicks.DbType =DbType.Int64;
                        if (obj.NoOfTicks == null)
                        {
                            prmNoOfTicks.Value = DBNull.Value;
                        }
                        else
                        {
                            prmNoOfTicks.Value = obj.NoOfTicks;
                        }
                        strWhere += " [NoOfTicks]=@NoOfTicks OR ";
                        lstParameters.Add(prmNoOfTicks);
                     }



                    

                    if (obj.LastTickDate != null)
                    {
                        DbParameter prmLastTickDate = con.createParameter();
                        prmLastTickDate.ParameterName = "@LastTickDate";
                        prmLastTickDate.DbType =DbType.DateTime;
                        if (obj.LastTickDate == null)
                        {
                            prmLastTickDate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmLastTickDate.Value = obj.LastTickDate;
                        }
                        strWhere += " [LastTickDate]=@LastTickDate OR ";
                        lstParameters.Add(prmLastTickDate);
                     }



                    

                    if (obj.TotalSpendTime != -1)
                    {
                        DbParameter prmTotalSpendTime = con.createParameter();
                        prmTotalSpendTime.ParameterName = "@TotalSpendTime";
                        prmTotalSpendTime.DbType =DbType.Int64;
                        if (obj.TotalSpendTime == null)
                        {
                            prmTotalSpendTime.Value = DBNull.Value;
                        }
                        else
                        {
                            prmTotalSpendTime.Value = obj.TotalSpendTime;
                        }
                        strWhere += " [TotalSpendTime]=@TotalSpendTime OR ";
                        lstParameters.Add(prmTotalSpendTime);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("OR"));

                    

            

            List<RegisteredCourses> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<RegisteredCourses> SearchOrLike(RegisteredCourses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<RegisteredCourses> lstRet = SearchOrLike(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                
        


       
        



    }
}











            